package com.iv.durian.cloud.facade;

import com.iv.durian.cloud.Serve;
import com.iv.durian.cloud.Student;
import org.springframework.cloud.openfeign.FeignClient;
import org.springframework.stereotype.Component;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;

import java.util.List;

@Component
@FeignClient(name = Serve.SERVICE_NAME)
@RequestMapping("/service/student")
public interface StudentFacade {

    @RequestMapping(path = "/get/{studentId}" ,method = RequestMethod.GET)
    Student get(@PathVariable(value = "studentId") Integer studentId);

    @RequestMapping(value = "/getByName/{name}", method = RequestMethod.GET)
    Student get(@PathVariable(value = "name") String name);

    @RequestMapping(value = "/add", method = RequestMethod.POST)
    void add(@RequestBody Student student);

    @RequestMapping(value = "/update", method = RequestMethod.POST)
    void update(@RequestBody Student student);

    @RequestMapping(value = "/remove/{studentId}", method = RequestMethod.POST)
    int remove(@PathVariable(name = "studentId") Integer studentId);

    @RequestMapping(value = "/count/{studentId}", method = RequestMethod.GET)
    int count(@PathVariable(name = "studentId") Integer studentId);

    @RequestMapping(value = "/list/{studentId}", method = RequestMethod.GET)
    List<Student> list(@PathVariable(name = "studentId") Integer studentId, @PathVariable(name = "offset") Integer offset, @PathVariable(name = "limit") Integer limit);
}
